<?php

namespace App\Console\Commands;

use App\Jobs\Tcm\InitMemberBookCollect;
use App\Models\Member;
use Illuminate\Console\Command;

class InitMemberTcmBookCollect extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'tcm:init_member_book_collect';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '填充用户书架';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        Member::chunkById(200, function ($members){
            InitMemberBookCollect::dispatch($members->pluck('id')->all());
        });

        return Command::SUCCESS;
    }
}
